<html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Hammerspoon docs: Keychain</title>
    <style type="text/css">
      a { text-decoration: none; }
      a:hover { text-decoration: underline; }
      th { background-color: #DDDDDD; vertical-align: top; padding: 3px; }
      td { width: 100%; background-color: #EEEEEE; vertical-align: top; padding: 3px; }
      table { width: 100% ; border: 1px solid #0; text-align: left; }
      section > table table td { width: 0; }
    </style>
    <link rel="stylesheet" href="docs.css" type="text/css" media="screen" />
  </head>
  <body>
    <header>
      <h1><a href="./index.html">docs</a> &raquo; Keychain</h1>
      <p>Get and Add items from Keychain. Provides no hotkeys and maintains no state</p>
<p>Example usage:</p>
<div class="highlight"><pre><span></span><span class="n">spoon</span><span class="p">.</span><span class="n">Keychain</span><span class="p">.</span><span class="n">addItem</span><span class="p">{</span><span class="n">service</span><span class="o">=</span><span class="s2">&quot;mynas.local&quot;</span><span class="p">,</span> <span class="n">account</span><span class="o">=</span><span class="s2">&quot;myname&quot;</span><span class="p">,</span> <span class="n">password</span><span class="o">=</span><span class="s2">&quot;secret&quot;</span><span class="p">}</span>
   <span class="n">item</span> <span class="o">=</span> <span class="n">spoon</span><span class="p">.</span><span class="n">Keychain</span><span class="p">.</span><span class="n">getItem</span><span class="p">{</span><span class="n">service</span><span class="o">=</span><span class="s2">&quot;mynas.local&quot;</span><span class="p">,</span> <span class="n">account</span><span class="o">=</span><span class="s2">&quot;myname&quot;</span><span class="p">}</span>
   <span class="nb">print</span><span class="p">(</span><span class="n">item</span><span class="p">.</span><span class="n">password</span><span class="p">)</span>
</pre></div>
<p>Tyler Thrailkill <a href="mailto:tyler.b.thrailkill@gmail.com">tyler.b.thrailkill@gmail.com</a></p>
<p>https://github.com/snowe2010</p>

      </header>
      <h3>API Overview</h3>
      <ul>
        <li>Deprecateds - API features which will be removed in an future release</li>
          <ul>
            <li><a href="#login_keychain">login_keychain</a></li>
          </ul>
        <li>Variables - Configurable values</li>
          <ul>
            <li><a href="#logger">logger</a></li>
          </ul>
        <li>Methods - API calls which can only be made on an object returned by a constructor</li>
          <ul>
            <li><a href="#addItem">addItem</a></li>
            <li><a href="#getItem">getItem</a></li>
          </ul>
      </ul>
      <h3>API Documentation</h3>
        <h4 class="documentation-section">Deprecateds</h4>
          <section id="login_keychain">
            <a name="//apple_ref/cpp/Deprecated/login_keychain" class="dashAnchor"></a>
            <h5><a href="#login_keychain">login_keychain</a></h5>
            <table>
              <tr>
                <th>Signature</th>
                <td><code>Keychain:login_keychain(name)</code></td>
              </tr>
              <tr>
                <th>Type</th>
                <td>Deprecated</td>
              </tr>
              <tr>
                <th>Description</th>
                <td><p>Retrieve an item from the Login Keychain, returns nil if not found.</p>
</td>
              </tr>
              <tr>
                  <th>Notes</th>
                  <td><ul>
<li>Use getItem() instead.</li>
</ul>
</td>
              </tr>
              <tr>
                <th>Source</th>
                <td><a href="https://github.com/Hammerspoon/Spoons/blob/master/Source/Keychain.spoon/init.lua#L64">Source/Keychain.spoon/init.lua line 64</a></td>
              </tr>
            </table>
          </section>
        <h4 class="documentation-section">Variables</h4>
          <section id="logger">
            <a name="//apple_ref/cpp/Variable/logger" class="dashAnchor"></a>
            <h5><a href="#logger">logger</a></h5>
            <table>
              <tr>
                <th>Signature</th>
                <td><code>Keychain.logger</code></td>
              </tr>
              <tr>
                <th>Type</th>
                <td>Variable</td>
              </tr>
              <tr>
                <th>Description</th>
                <td><p>Logger object used within the Spoon. Can be accessed to set the default log level for the messages coming from the Spoon.</p>
</td>
              </tr>
              <tr>
                <th>Source</th>
                <td><a href="https://github.com/Hammerspoon/Spoons/blob/master/Source/Keychain.spoon/init.lua#L25">Source/Keychain.spoon/init.lua line 25</a></td>
              </tr>
            </table>
          </section>
        <h4 class="documentation-section">Methods</h4>
          <section id="addItem">
            <a name="//apple_ref/cpp/Method/addItem" class="dashAnchor"></a>
            <h5><a href="#addItem">addItem</a></h5>
            <table>
              <tr>
                <th>Signature</th>
                <td><code>Keychain:addItem(options)</code></td>
              </tr>
              <tr>
                <th>Type</th>
                <td>Method</td>
              </tr>
              <tr>
                <th>Description</th>
                <td><p>Add generic password to keychain.</p>
</td>
              </tr>
              <tr>
                  <th>Parameters</th>
                  <td><ul>
<li>options is a table with values for what keys to try locate with.<ul>
<li>password - the password</li>
<li>account - account name (required)</li>
<li>creator - creator, must be 4 characters</li>
<li>type - type, must be 4 characters</li>
<li>kind - kind of item</li>
<li>comment - comment</li>
<li>label - label (defaults to service name)</li>
<li>service - service name (required)</li>
</ul>
</li>
</ul>
</td>
              </tr>
              <tr>
                  <th>Returns</th>
                  <td></td>
              </tr>
              <tr>
                <th>Source</th>
                <td><a href="https://github.com/Hammerspoon/Spoons/blob/master/Source/Keychain.spoon/init.lua#L139">Source/Keychain.spoon/init.lua line 139</a></td>
              </tr>
            </table>
          </section>
          <section id="getItem">
            <a name="//apple_ref/cpp/Method/getItem" class="dashAnchor"></a>
            <h5><a href="#getItem">getItem</a></h5>
            <table>
              <tr>
                <th>Signature</th>
                <td><code>Keychain:getItem(options)</code></td>
              </tr>
              <tr>
                <th>Type</th>
                <td>Method</td>
              </tr>
              <tr>
                <th>Description</th>
                <td><p>Retrieve an item from the Login Keychain. Return nil if not found and otherwise a table with found data.</p>
</td>
              </tr>
              <tr>
                  <th>Parameters</th>
                  <td><ul>
<li>options is a table with values for what keys to try locate with.<ul>
<li>account - account name</li>
<li>creator - creator, must be 4 characters</li>
<li>type - type, must be 4 characters</li>
<li>kind - kind of item</li>
<li>comment - comment</li>
<li>label - label (defaults to service name)</li>
<li>service - service name</li>
</ul>
</li>
</ul>
</td>
              </tr>
              <tr>
                  <th>Returns</th>
                  <td></td>
              </tr>
              <tr>
                  <th>Notes</th>
                  <td><ul>
<li>If multiple possibles matches just the first one is found.</li>
</ul>
</td>
              </tr>
              <tr>
                <th>Source</th>
                <td><a href="https://github.com/Hammerspoon/Spoons/blob/master/Source/Keychain.spoon/init.lua#L82">Source/Keychain.spoon/init.lua line 82</a></td>
              </tr>
            </table>
          </section>
  </body>
</html>